package main.model.rdf;

public class FilterElement {

	private String subject = "",
			subjectType = "",
			predicat = "",
			predicatType = "",
			object = "",
			objectType = "",
			before = "",
			after = "";
	
	public enum TYPE {AND, OR}
	
	TYPE type = TYPE.OR;
	
	public enum MODE {NORMAL, NESTED, NESTED_SUBFILTER, SUBFILTER, LOCATION, DATE}
	
	MODE mode = MODE.NORMAL;
	
	double radius = 0;
	
	public FilterElement(String subject, String subjectType, String predicat,
			String predicatType, String object, String objectType, TYPE type) {
		super();
		if (subject != null) this.subject = subject;
		if (subjectType != null) this.subjectType = subjectType;
		if (predicat != null) this.predicat = predicat;
		if (predicatType != null) this.predicatType = predicatType;
		if (object != null) this.object = object;
		if (objectType != null) this.objectType = objectType;
		this.mode = MODE.NORMAL;
		this.type = type;
	}

	/**
	 * @return the subject
	 */
	public String getSubject() {
		return subject;
	}

	/**
	 * @param subject the subject to set
	 */
	public void setSubject(String subject) {
		this.subject = subject;
	}

	/**
	 * @return the subjectType
	 */
	public String getSubjectType() {
		return subjectType;
	}

	/**
	 * @param subjectType the subjectType to set
	 */
	public void setSubjectType(String subjectType) {
		this.subjectType = subjectType;
	}

	/**
	 * @return the predicat
	 */
	public String getPredicat() {
		return predicat;
	}

	/**
	 * @param predicat the predicat to set
	 */
	public void setPredicat(String predicat) {
		this.predicat = predicat;
	}

	/**
	 * @return the subFilter
	 */
	public MODE getMode() {
		return mode;
	}
	
	/**
	 * @param subfilter the subfilter to set
	 */
	public void setMode(MODE mode) {
		this.mode = mode;
	}
	
	/**
	 * @return the type
	 */
	public TYPE getType() {
		return type;
	}
	
	/**
	 * @param type the type to set
	 */
	public void setType(TYPE type) {
		this.type = type;
	}

	/**
	 * @return the predicatType
	 */
	public String getPredicatType() {
		return predicatType;
	}

	/**
	 * @param predicatType the predicatType to set
	 */
	public void setPredicatType(String predicatType) {
		this.predicatType = predicatType;
	}

	/**
	 * @return the object
	 */
	public String getObject() {
		return object;
	}

	/**
	 * @param object the object to set
	 */
	public void setObject(String object) {
		this.object = object;
	}

	/**
	 * @return the objectType
	 */
	public String getAfter() {
		return after;
	}

	/**
	 * @param objectType the objectType to set
	 */
	public void setAfter(String after) {
		this.after = after;
	}
	
	/**
	 * @return the objectType
	 */
	public String getBefore() {
		return before;
	}

	/**
	 * @param objectType the objectType to set
	 */
	public void setBefore(String before) {
		this.before = before;
	}
	
	/**
	 * @return the objectType
	 */
	public double getRadius() {
		return radius;
	}

	/**
	 * @param objectType the objectType to set
	 */
	public void setRadius(double radius) {
		this.radius = radius;
	}
	
	@Override
	public String toString() {
		return (this.type == TYPE.OR?"LUB":"I") 
					+ " <" + this.subject + "," + this.subjectType + ">" 
					+ " <" + this.predicat + "," + this.predicatType 
					+ ">" + " <" + this.object + "," +
					this.objectType + ">";
	}
	
	public RDF toRDF()
	{		
		RdfField subject = new RdfField(this.getValue(this.subject), 
				this.getValue(this.subjectType));
		RdfField property = new RdfField(this.getValue(this.predicat), 
				this.getValue(this.predicatType));
		RdfField object = new RdfField(this.getValue(this.object), 
				this.getValue(this.objectType));
		RDF rdf = new RDF(subject, property, object);
		return rdf;
	}
	
	public String getValue(String in)
	{
		if (in == null || in == "") return "?";
		else return in;
	}
	
	/**
	 * @return the after
	 */
	public String getObjectType() {
		return objectType;
	}

	/**
	 * @param after the after to set
	 */
	public void setObjectType(String objectType) {
		this.objectType = objectType;
	}
}
